package com.zdy.syn;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * Created by 逸足天涯
 * on 3/9/2020.
 */
//测试JUC 安全类型集合
public class TestJUC {
    CopyOnWriteArrayList<String> list =new CopyOnWriteArrayList<>();

    public static void main(String[] args) {
        CopyOnWriteArrayList<String> lists = new CopyOnWriteArrayList<>();
        for (int i = 0; i < 1000; i++) {
            new Thread(()->{
                lists.add(Thread.currentThread().getName());
            }).start();

        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(lists.size());
    }
}
